/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rise.remi.network;

/**
 *
 * @author Riseremi
 */
public class PingYourself implements Runnable {
    private long lastTime = System.currentTimeMillis();
    private final Network network;

    public PingYourself(final Network network) {
        this.network = network;
    }

    @Override
    public void run() {
        while (true) {
            if (System.currentTimeMillis() - lastTime >= 5000) {
                network.sendData(new NetworkMessage(NetworkMessage.PING, ""));
                lastTime = System.currentTimeMillis();
                System.out.println(network.getClass().getSimpleName() + "'s ping sent");
            }
        }
    }

}
